<?php
$cs = Yii::app()->clientScript;
$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/scripts/fancybox/jquery.fancybox-1.3.4.pack.js');
$cs->registerCssFile(Yii::app()->theme->baseUrl.'/scripts/fancybox/jquery.fancybox-1.3.4.css');
?>

<div class="box">
    <h2 class="title"><?php echo Yii::t('site/general','Contact'); ?></h2>
    <div class="contact">
        <div class="info">
            <div class="company">
                <h3><?php echo Yii::t('site/general','Company Information'); ?></h3>
                <ul>                                                                    
                    <li><strong><?php echo $this->getSiteNameByLanguage(); ?></strong></li>
                    <li><?php echo $this->getCompanyAddressByLanguage(); ?></li>
                    <li>Tel:  <?php echo SiteSettings::CONTACT_PHONE; ?></li>
                    <li>Email: <?php echo SiteSettings::CONTACT_EMAIL; ?></li>
                </ul>
            </div>
            <a id="lnk-show-map" href="<?php echo baseUrl().$this->createUrl('/site/showMap',array('locale'=>Yii::app()->language)); ?>"><img width="280px" height="187px" src="<?php echo themeUrl(); ?>/images/small_map.jpg" alt="" /></a>
            <br />
            <span style="color: #666666;">(<?php echo Yii::t('site/general','Please click the map above to view with larger size'); ?>)</span>
        </div>

        <?php $form = $this->beginWidget('CActiveForm', array(
            'id' => 'contact-form',
            'enableAjaxValidation' => false,
            'enableClientValidation' => true,
            'clientOptions' => array(
                'validateOnSubmit' => true,
                /*'afterValidate'=>"js:function(form,data,hasError){
                    
                }"*/
            ),
            'enableAjaxValidation' => false,
        )); ?>
        <?php if (user()->hasFlash('send_contact_success')) : ?>
            <div class="successMessage" style="width: 240px; margin-left: 290px;"><?php echo user()->getFlash('send_contact_success'); ?></div>
        <?php endif; ?>
        <table class="contact-form" align="center" cellspacing="4" cellpadding="4" border="0" style="margin-bottom:100px;">
            <tbody>
                <tr><td height="1" colspan="2"></td></tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'name'); ?></td>
                </tr>
                <tr>
                    <td>
                        <?php echo $form->textField($model,'name',array('class'=>'textbground')); ?>
                        <?php echo $form->error($model, 'name'); ?>
                    </td> 
                </tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'address'); ?></td>
                </tr>
                <tr>
                    <td align="left" class="style_nd">
                        <?php echo $form->textField($model,'address',array('class'=>'textbground')); ?>
                        <?php echo $form->error($model, 'address'); ?>
                    </td>
                </tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'phone'); ?></td>
                </tr>
                <tr>
                    <td align="left" class="style_nd">
                        <?php echo $form->textField($model,'phone',array('class'=>'textbground')); ?>
                        <?php echo $form->error($model, 'phone'); ?>
                    </td>
                </tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'fax'); ?></td>
                </tr>
                <tr>
                    <td align="left" class="style_nd">
                        <?php echo $form->textField($model,'fax',array('class'=>'textbground')); ?>
                        <?php echo $form->error($model, 'fax'); ?>
                    </td>
                </tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'email'); ?></td>
                </tr>
                <tr>
                    <td align="left" class="style_nd">
                        <?php echo $form->textField($model,'email',array('class'=>'textbground')); ?>
                        <?php echo $form->error($model, 'email'); ?>
                    </td>
                </tr>
                <tr>
                    <td><?php echo $form->labelEx($model, 'content'); ?></td>
                </tr>
                <tr>
                    <td align="left" class="style_nd">
                        <?php echo $form->textArea($model,'content',array('class'=>'textbground','rows'=>5)); ?>
                        <?php echo $form->error($model, 'content'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="style_nd" colspan="2">
                        <table align="center" width="57%" cellspacing="0" cellpadding="0" border="0">
                            <tbody>
                                <tr>
                                    <td align="right" width="28%">
                                        <label><input type="submit" style="border:#D5D5D5 solid 1px; border-bottom:solid #969696 1px; border-right:solid #969696 1px; width:auto" value="<?php echo Yii::t('site/general','Send'); ?>" name="Submit" class="buttonStyle" /></label>
                                    </td>
                                    <td width="72%">
                                        <label>
                                            &nbsp;&nbsp;
                                            <input type="reset" style="border:#D5D5D5 solid 1px; border-bottom:solid #969696 1px; border-right:solid #969696 1px; width:auto" value="<?php echo Yii::t('site/general','Reset'); ?>" name="Submit2" class="buttonStyle" />
                                        </label>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
        <?php $this->endWidget(); ?>
    </div>  
</div>

<script type="text/javascript">
$('#lnk-show-map').click(function(){
    var url = $(this).attr('href');
    $.fancybox({
        'type' : 'iframe',
        'href' : url,
        'titleShow' : false,
        'transitionIn' : 'none',
        'transitionOut' : 'none',
        'width' : 520,
        'height' : 520
    });
    return false;    
});
</script>